using System;
using System.Collections.Generic;
using System.Text;

using AIFSDataAccessLayer;
using AIFSCMSDataAccessLayer.DaoImpl;

using AIFSContentManagementSystem.DomainObjects;

namespace AIFSContentManagementSystem
{
    using ArticleManagement;
    using CriteriaManagement;
    
    public sealed class DefaultManagerContext : IManagerContext
    {
        #region IManagerContext Members

        public IArticleManager GetArticleManager()
        {
            IArticleManager articleManager = new ArticleManager();
            articleManager.ManagerContext = this;

            //Assign daos
            articleManager.ArticleDao = new ArticleDao(this.DataExecutionContext);
            articleManager.FragmentDao = new FragmentDao(this.DataExecutionContext);

            //Assign article parser
            articleManager.Parser = new DomainObjects.Parser();
            return articleManager;
        }

        public ICriteriaManager GetCriteriaManager()
        {
            ICriteriaManager criteriaManager = new CriteriaManager();
            criteriaManager.ManagerContext = this;

            //Assign daos
            criteriaManager.CriteriaDao = new CriteriaDao(this.DataExecutionContext);

            //assign criterion expression factory
            criteriaManager.CriterionExpressionFactory = new DefaultCriterionExpressionFactory();
            criteriaManager.CriteriaAsserter = new CriteriaAsserter();
            return criteriaManager;
        }

        IDataExecutionContext dataExecutionContext;

        public IDataExecutionContext DataExecutionContext
        {
            get
            {
                return dataExecutionContext;
            }
            set
            {
                dataExecutionContext = value;
            }
        }

        #endregion
    }
}
